﻿// Study0806.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
// 第八章 多态 纯虚函数和抽象类

#include <iostream>
using namespace std;

class Base1
{
public:
	virtual void display() const = 0;
};

class Base2:public Base1
{
public:
	void display() const override;
};
void Base2::display() const
{
	cout << "调用Base2的display函数" << endl;
}

class Derived:public Base2
{
public:
	void display() const override;
};
void Derived::display() const
{
	cout << "调用Derived的display函数" << endl;
}
void func(Base1* b)
{
	b->display();
}
int main()
{
	Base2 base2;
	Derived der;
	func(&base2);
	func(&der);
	return 0;
}


